<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>类及对象构建算法</title>
	</head>
	<body>
		<script>
		var Person = function(firstAndLast) {
					var arr=firstAndLast.split(" ");
					firstname=arr[0];
					lastname=arr[1];
					//getFirstName(), getLastName(), 
					//getFullName(), setFirstName(first), 
					//setLastName(last), and setFullName(firstAndLast).
					this.getFirstName=function(){return firstname;};
					this.getLastName=function(){return lastname;};
					this.getFullName=function(){return firstname+' '+lastname;}
					this.setFirstName=function(fist){firstname=fist;};
					this.setLastName=function(last){lastname=last;};
					this.setFullName=function(firstAndLast){var arr=firstAndLast.split(" ");
					firstname=arr[0];
					lastname=arr[1];}
				    return this;
				};
		
		var bob = new Person('Bob Ross');
		//bob.getFullName();	
		//document.write(bob.firstname);
		document.write(bob.getFirstName());
		</script>
	</body>
</html>
